Skip to content

Update ContactsList.swift#11

Open
JCKL wants to merge 1 commit into
apple:mainfrom
JCKL:patch-1
Open

Update ContactsList.swift#11
JCKL wants to merge 1 commit into
apple:mainfrom
JCKL:patch-1

Conversation

@JCKL

@JCKL JCKL commented Jan 12, 2024

Copy link
Copy Markdown

When adding fields to Contact, the original implementation of listID didn't guarantee updates when additional fields were added to Contact unless the new fields were also added here which gets very clunky.

I think a better approach is to make the listID by combining self.id with self.userModificationDate.

This guarantees updates when new fields are added to Contact and I think is a better pattern for developers to implement in their own projects.

When adding fields to Contact, the original implementation didn't guarantee updates when additional fields were added to Contact unless the additional fields were also added here which gets very clunky.

I think a better approach is to make the listID by combining self.id with self.userModificationDate.

This guarantees updates when new fields are added to Contact and I think is a better pattern for developers to implement going forward.
@malhal

malhal commented Apr 16, 2025

Copy link
Copy Markdown

I think the reason for the lack of updates is a mistake that ContactView shouldn't have @State. @State should always be private and have an inline init of the initial value otherwise use @Binding to pass write down access to the parent's @State.


It is a bad idea to name Views using model names too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants